package com.yunyouyi.cpicture.infrastructure.exception;

/**
 * 异常工具类
 */
public class ThrowUtils {
    /**
     * 条件成立抛异常
     * @param condition
     * @param runtimeException 异常
     */
    public static void throwIf(boolean condition,RuntimeException runtimeException) {
        if(condition){
            throw  runtimeException;
        }
    }

    /**
     * 条件成立抛异常
     * @param condition
     * @param errorCode 错误码
     */
    public static void throwIf(boolean condition, ErrorCode errorCode){
        throwIf(condition,new BusinessException(errorCode));
    }
    /**
     * 条件成立抛异常
     * @param condition
     * @param errorCode 错误码
     */
    public static void throwIf(boolean condition, ErrorCode errorCode, String message){
        throwIf(condition,new BusinessException(errorCode,message));
    }
}
